# -*- coding:utf-8 -*-

from sqlalchemy import Column, Integer, String, DateTime, Text
from config.database import BaseMixin, Base


class SearchTask(Base, BaseMixin):
    """
    搜索任务配置表 - 配置自动搜索任务
    """
    __tablename__ = "search_task"
    
    # 任务基本信息
    task_name = Column(String(100), nullable=False, comment='任务名称')
    keyword = Column(String(200), nullable=False, comment='搜索关键词')
    
    # 时间配置
    total_time = Column(Integer, nullable=False, default=60, comment='总时间（秒）')
    interval_time = Column(Integer, nullable=True, comment='计算出的间隔时间（秒）')
    
    # 任务状态
    task_status = Column(String(20), nullable=True, default='stopped', comment='任务状态: stopped/running/paused')
    
    # 统计信息
    search_count = Column(Integer, nullable=True, default=0, comment='搜索次数')
    last_search_time = Column(DateTime, nullable=True, comment='最后搜索时间')
    
    # 其他配置
    auto_order = Column(String(1), nullable=True, default='1', comment='是否自动下单（0否 1是）')
    skip_first_search = Column(String(1), nullable=True, default='0', comment='首次搜索不自动下单（0否 1是）')
    enable_jitter = Column(String(1), nullable=True, default='1', comment='抖动搜索（0否 1是）')
    remark = Column(String(500), nullable=True, comment='备注')
    status = Column(String(1), nullable=True, default='0', comment='状态（0正常 1停用）')

